package controller;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import sql.TasksForUserStoryDao;

/**
 * Servlet implementation class TaskboardStatusUpdateHandler
 */
@WebServlet("/TaskboardStatusUpdateHandler")
public class TaskboardStatusUpdateHandler extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public TaskboardStatusUpdateHandler() {
        super();
    }

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int taskId = Integer.parseInt(request.getParameter("task_id"));
		int status = Integer.parseInt(request.getParameter("status"));

		TasksForUserStoryDao tasksForUserStoryDao = new TasksForUserStoryDao();
		try {
			tasksForUserStoryDao.updateTaskStatus(taskId, status);
		} catch (ClassNotFoundException | SQLException e) {
			e.printStackTrace();
		}
	}

}
